package com.shunda.system.service.impl;

import java.util.List;

import com.shunda.common.core.domain.entity.SysOilPrice;
import com.shunda.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.shunda.system.mapper.SysOilPriceMapper;

import com.shunda.system.service.ISysOilPriceService;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author shunda
 * @date 2025-03-27
 */
@Service
public class SysOilPriceServiceImpl implements ISysOilPriceService {
    @Autowired
    private SysOilPriceMapper sysOilPriceMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public SysOilPrice selectSysOilPriceById(Long id) {
        return sysOilPriceMapper.selectSysOilPriceById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param sysOilPrice 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<SysOilPrice> selectSysOilPriceList(SysOilPrice sysOilPrice) {
        return sysOilPriceMapper.selectSysOilPriceList(sysOilPrice);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param sysOilPrice 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertSysOilPrice(SysOilPrice sysOilPrice) {
        sysOilPrice.setCreateTime(DateUtils.getNowDate());
        return sysOilPriceMapper.insertSysOilPrice(sysOilPrice);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param sysOilPrice 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateSysOilPrice(SysOilPrice sysOilPrice) {
        sysOilPrice.setUpdateTime(DateUtils.getNowDate());
        return sysOilPriceMapper.updateSysOilPrice(sysOilPrice);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteSysOilPriceByIds(Long[] ids) {
        return sysOilPriceMapper.deleteSysOilPriceByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteSysOilPriceById(Long id) {
        return sysOilPriceMapper.deleteSysOilPriceById(id);
    }

    @Override
    public Boolean checkRepetion(SysOilPrice sysOilPrice) {
        Long deptId = sysOilPrice.getDeptId();
        String oilType = sysOilPrice.getOilType();
        String oilCode = sysOilPrice.getOilCode();
        SysOilPrice selectOilPrice = new SysOilPrice();
        selectOilPrice.setDeptId(deptId);
        selectOilPrice.setOilType(oilType);
        selectOilPrice.setOilCode(oilCode);
        List<SysOilPrice> sysOilPrices = sysOilPriceMapper.selectSysOilPriceList(selectOilPrice);
        if (sysOilPrices.size() > 0) {
            return false;
        }
        return true;
    }
}
